var t;
var timer_on = 0;
function start_timer(a_time) {
  while(timer_on>0) {
    clearTimeout(t);
    timer_on--;
  }

  timer_on++;

  timer(a_time);
}

function timer(a_time) {
  time = a_time;
  document.getElementById("time").innerHTML = time;
  if(time == 0) {
    clearTimeout(t);
    checkanswers(document.getElementById("form1"));   
    time = 30;
    return;
  }
  time = time - 1;
  t = setTimeout("timer(time)", 1000);
}

